/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: 
 * License Type: Evaluation
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tan_tipoanotacionDAOImpl implements orm.dao.Tan_tipoanotacionDAO {
	public Tan_tipoanotacion loadTan_tipoanotacionByORMID(int ta_id_tipoanotacion) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return loadTan_tipoanotacionByORMID(session, ta_id_tipoanotacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion getTan_tipoanotacionByORMID(int ta_id_tipoanotacion) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return getTan_tipoanotacionByORMID(session, ta_id_tipoanotacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByORMID(int ta_id_tipoanotacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return loadTan_tipoanotacionByORMID(session, ta_id_tipoanotacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion getTan_tipoanotacionByORMID(int ta_id_tipoanotacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return getTan_tipoanotacionByORMID(session, ta_id_tipoanotacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByORMID(PersistentSession session, int ta_id_tipoanotacion) throws PersistentException {
		try {
			return (Tan_tipoanotacion) session.load(orm.Tan_tipoanotacion.class, new Integer(ta_id_tipoanotacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion getTan_tipoanotacionByORMID(PersistentSession session, int ta_id_tipoanotacion) throws PersistentException {
		try {
			return (Tan_tipoanotacion) session.get(orm.Tan_tipoanotacion.class, new Integer(ta_id_tipoanotacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByORMID(PersistentSession session, int ta_id_tipoanotacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tan_tipoanotacion) session.load(orm.Tan_tipoanotacion.class, new Integer(ta_id_tipoanotacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion getTan_tipoanotacionByORMID(PersistentSession session, int ta_id_tipoanotacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tan_tipoanotacion) session.get(orm.Tan_tipoanotacion.class, new Integer(ta_id_tipoanotacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion[] listTan_tipoanotacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return listTan_tipoanotacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion[] listTan_tipoanotacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return listTan_tipoanotacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion[] listTan_tipoanotacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_tipoanotacion as Tan_tipoanotacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tan_tipoanotacion[]) list.toArray(new Tan_tipoanotacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion[] listTan_tipoanotacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_tipoanotacion as Tan_tipoanotacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tan_tipoanotacion[]) list.toArray(new Tan_tipoanotacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return loadTan_tipoanotacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return loadTan_tipoanotacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tan_tipoanotacion[] tan_tipoanotacions = listTan_tipoanotacionByQuery(session, condition, orderBy);
		if (tan_tipoanotacions != null && tan_tipoanotacions.length > 0)
			return tan_tipoanotacions[0];
		else
			return null;
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tan_tipoanotacion[] tan_tipoanotacions = listTan_tipoanotacionByQuery(session, condition, orderBy, lockMode);
		if (tan_tipoanotacions != null && tan_tipoanotacions.length > 0)
			return tan_tipoanotacions[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTan_tipoanotacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return iterateTan_tipoanotacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTan_tipoanotacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.DocumentacionPersistentManager.instance().getSession();
			return iterateTan_tipoanotacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTan_tipoanotacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_tipoanotacion as Tan_tipoanotacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTan_tipoanotacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_tipoanotacion as Tan_tipoanotacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion createTan_tipoanotacion() {
		return new orm.Tan_tipoanotacion();
	}
	
	public boolean save(orm.Tan_tipoanotacion tan_tipoanotacion) throws PersistentException {
		try {
			orm.DocumentacionPersistentManager.instance().saveObject(tan_tipoanotacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tan_tipoanotacion tan_tipoanotacion) throws PersistentException {
		try {
			orm.DocumentacionPersistentManager.instance().deleteObject(tan_tipoanotacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tan_tipoanotacion tan_tipoanotacion)throws PersistentException {
		try {
			orm.Tan_anotacion[] lTan_anotacions = tan_tipoanotacion.tan_anotacion.toArray();
			for(int i = 0; i < lTan_anotacions.length; i++) {
				lTan_anotacions[i].setTa_id_tipoanotacion(null);
			}
			return delete(tan_tipoanotacion);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tan_tipoanotacion tan_tipoanotacion, org.orm.PersistentSession session)throws PersistentException {
		try {
			orm.Tan_anotacion[] lTan_anotacions = tan_tipoanotacion.tan_anotacion.toArray();
			for(int i = 0; i < lTan_anotacions.length; i++) {
				lTan_anotacions[i].setTa_id_tipoanotacion(null);
			}
			try {
				session.delete(tan_tipoanotacion);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tan_tipoanotacion tan_tipoanotacion) throws PersistentException {
		try {
			orm.DocumentacionPersistentManager.instance().getSession().refresh(tan_tipoanotacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tan_tipoanotacion tan_tipoanotacion) throws PersistentException {
		try {
			orm.DocumentacionPersistentManager.instance().getSession().evict(tan_tipoanotacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_tipoanotacion loadTan_tipoanotacionByCriteria(Tan_tipoanotacionCriteria tan_tipoanotacionCriteria) {
		Tan_tipoanotacion[] tan_tipoanotacions = listTan_tipoanotacionByCriteria(tan_tipoanotacionCriteria);
		if(tan_tipoanotacions == null || tan_tipoanotacions.length == 0) {
			return null;
		}
		return tan_tipoanotacions[0];
	}
	
	public Tan_tipoanotacion[] listTan_tipoanotacionByCriteria(Tan_tipoanotacionCriteria tan_tipoanotacionCriteria) {
		return tan_tipoanotacionCriteria.listTan_tipoanotacion();
	}
}
